package cn.com.chengmandian.bike.controller;

import cn.com.chengmandian.bike.dto.NearNoparkingDto;
import cn.com.chengmandian.bike.model.vo.OperationNoparkingVo;
import cn.com.chengmandian.bike.model.vo.OperationStationVo;
import cn.com.chengmandian.bike.service.IEbOperationNoparkingService;
import cn.com.chengmandian.bike.service.IEbOperationStationService;
import cn.com.chengmandian.core.web.pojo.AgentInfo;
import cn.com.chengmandian.core.web.pojo.AjaxResult;
import cn.com.chengmandian.core.web.utils.LocalMapUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "禁停区相关接口")
@RestController
@RequestMapping("/operation/noparking")
public class EbOperationNoparkingController {
    @Autowired
    private IEbOperationNoparkingService operationNoparkingService;

    @ApiOperation("获取禁停区列表(无需登录)")
    @GetMapping("/list")
    public AjaxResult<List<OperationNoparkingVo>> getNoparkingList() {
        AgentInfo agentInfo = LocalMapUtil.getAgentInfo();
        Assert.notNull(agentInfo.getAreaId(), "缺少运营区");
        return AjaxResult.success(operationNoparkingService.getNoparkingList(agentInfo.getAreaId()));
    }

    @ApiOperation("附近禁停区列表(无需登录)")
    @GetMapping("/near/list")
    public AjaxResult<List<OperationNoparkingVo>> getNearNoparkingList(NearNoparkingDto dto){
        AgentInfo agentInfo = LocalMapUtil.getAgentInfo();
        Assert.notNull(agentInfo.getAreaId(), "缺少运营区");
        Assert.notNull(dto.getLat(), "缺少维度");
        Assert.notNull(dto.getLng(), "缺少经度");
        return AjaxResult.success(operationNoparkingService.getNearNoparkingList(agentInfo.getAreaId(), dto.getLat(), dto.getLng()));
    }
}
